#include <iostream>
#include "hv/HttpServer.h"
#include "router.h"
#include "../utils/dd_token.h"
#include "../sql/DDRedis.h"
#include "../sql/SQLHelper.h"

using namespace hv;
using namespace ddoffice;


int main2() {
    std::string secretKey = "your_secret_key";
    dd_token tokenGenerator(secretKey);

    std::string userId = "user123";
    std::string token = tokenGenerator.generateToken(userId);
    std::cout << "Generated token: " << token << std::endl;
    std::string t_userid = "-1";
    bool isValid = tokenGenerator.verifyToken(token, t_userid);
    if (isValid) {
        std::cout << "Token verification successful. "<< t_userid << std::endl;
    } else {
        std::cout << "Token verification failed." << std::endl;
    }

    return 0;
}


void initStore() {
    SQLHelper::getInstance();
    cout << "init mysql success" <<endl;
    // Connect to Redis server
    if (DDRedis::getInstance()->connect()){

    }
    cout << "init redis success" <<endl;
}

int main() {
//    main2();
//    main3();
    initStore();

    HttpService router;
    Router::Register(router);
    HttpServer server;
    server.service = &router;
    server.port = 8080;
    server.run();
    return 0;
}

